#include<bits/stdc++.h>
using namespace std;
double a[100005],b[100005],v[100005],d[100005],c[1000005],t[100005],n,m,l,V,x;
pair<int,int> pa[100005];
vector<bool> ve;
bool check;
int kkk=0;
void pianfen(int now,vector<bool> v,int sum,int ccc){
    if(now==m){
        for(int i=0;i<sum;i++){
            check=0;
            for(int j=pa[i].first;j<=pa[i].second;j++)check=check|v[j];
            if(!check)return;
        }
        kkk=max(kkk,ccc);
    }
    else{
        v.push_back(0);
        pianfen(now+1,v,sum,ccc+1);
        v.pop_back();
        v.push_back(1);
        pianfen(now+1,v,sum,ccc);
    }
}
void solve(){
    cin>>n>>m>>l>>V;
    for(int i=0;i<n;i++){
        cin>>d[i]>>v[i]>>a[i];
    }
    bool flag=0;
    int ans=0;
    for(int i=0;i<m;i++)cin>>b[i];
    for(int i=0;i<n;i++){
        flag=0;
        if(a[i]>0){
             if(v[i]>V){
                if(d[i]<=b[(int)m-1])ans++,flag=1;
                if(flag)pa[ans-1].first=lower_bound(b,b+(int)m,d[i])-b,pa[ans-1].second=(int)m-1;
             }
             else {
                x=(V*V-v[i]*v[i])/2/a[i];
                if(x+d[i]<b[(int)m-1])ans++,flag=1;
                if(flag)pa[ans-1].first=upper_bound(b,b+(int)m,d[i]+x)-b,pa[ans-1].second=(int)m-1;
//                cout<<x+d[i]<<endl;
             }

        }
        else if(a[i]==0){
            if(v[i]>V){
                if(d[i]<=b[(int)m-1])ans++,flag=1;
                if(flag)pa[ans-1].first=lower_bound(b,b+(int)m,d[i])-b,pa[ans-1].second=(int)m-1;
            }

        }
        else{
            if(v[i]>V){
                x=(V*V-v[i]*v[i])/2/a[i];
                if(d[i]+x<=b[0])continue;
                double *p=lower_bound(b,b+(int)m,d[i])-1,*q=upper_bound(b,b+(int)m,d[i]+x)-1;
                if(p!=b+(int)m&&*p<*q)ans++,flag=1;
                if(flag)pa[ans-1].first=(int)(p-b+1),pa[ans-1].second=(int)(q-b);

            }
        }
//        cout<<pa[ans-1].first<<' '<<pa[ans-1].second<<endl;
    }
    if(m<=20&&n<=20){
        kkk=0;
        pianfen(0,ve,ans,0);
        cout<<ans<<' '<<kkk<<endl;
    }
    else{
        for(int i=0;i<ans;i++){
    //        if(c[pa[i].first]==0)cnt++,c[pa[i].first]=1;
            c[pa[i].second]=1;
    //        cout<<pa[i].first<<' '<<pa[i].second<<endl;
        }
        int cnt=0;
        for(int i=0;i<m;i++)if(c[i]==1)t[cnt]=i,cnt++;
        for(int i=0;i<ans;i++){
            pa[i].first=t[lower_bound(t,t+cnt,pa[i].first)-t];
        }
        for(int i=0;i<m;i++)c[i]=0;
        cnt=0;
        for(int i=0;i<ans;i++){
            c[pa[i].first]=1;
        }
        for(int i=0;i<m;i++)if(c[i]==1)t[cnt]=i,cnt++,c[i]=0;
        for(int i=0;i<ans;i++){
            pa[i].second=t[lower_bound(t,t+cnt,pa[i].second)-t];
        }
        cnt=0;
        for(int i=0;i<ans;i++){
            if(pa[i].first==pa[i].second&&c[pa[i].first]==0)cnt++,c[pa[i].first]=1;
    //        cout<<pa[i].first<<' '<<pa[i].second<<endl;
        }
        cout<<ans<<' '<<m-cnt<<endl;
    }

}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t;
    cin>>t;
    while(t--)solve();
}
